package api

import (
	"api/basic/global"
	__ "api/basic/proto"
	"api/handler/request"
	"fmt"
	"github.com/gin-gonic/gin"
	"log"
	"net/http"
)

func OrderList(c *gin.Context) {

	r, err := global.S.OrderList(c, &__.OrderListReq{})
	if err != nil {
		log.Fatalf("could not greet: %v", err)
	}
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "订单列表",
		"data": r,
	})
}
func OrderAdd(c *gin.Context) {
	var data request.OrderAdd
	err := c.ShouldBind(&data)
	if err != nil {
		return
	}
	fmt.Println(data)
	r, err := global.S.OrderAdd(c, &__.OrderAddReq{
		UserId:      int64(data.UserId),
		GoodId:      int64(data.GoodId),
		OrderNumber: data.OrderNumber,
	})
	if err != nil {
		log.Fatalf("could not greet: %v", err)
	}
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "订单添加",
		"data": r,
	})

}
